function myJax(url,data,type,success){
  // 1. 创建xhr对象
  var xhr;
  try{
    xhr= new XMLHttpRequest();
  }catch(e){
    try{
      xhr = new ActiveXObject("Msxml2.XMLHTTP");
    }catch(e){
      try{
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
      }catch(e){
        alert("您的浏览器不支持AJAX，请更换！");
        return false;
      }
    }
  }
  //2.发送请求
  if (type.toUpperCase() == "GET"){
    xhr.open("get",url+"?"+data);
    xhr.send();
  }else{
    xhr.open("post",url);
    xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xhr.send(data);
  }
  //3.监听响应
  xhr.onreadystatechange=function () {
    if(xhr.readyState == 4){
      if (xhr.status == 200){
        success(xhr.responseText);
      }else{
        console.log(xhr.responseText);//获取到异常信息
      }
    }
  }
}